﻿using System.Globalization;
using FreshMeat.Xaml;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace XamlTest
{
   [TestClass]
   public class MathExtensionTest
   {
      [TestMethod]
      public void IntPlusIntTest()
      {
         var math = new MathExtension();
         var result = math.Convert(2, null, "+ 3", CultureInfo.CurrentCulture);
         Assert.IsInstanceOfType(result, typeof(int));
         Assert.AreEqual(5, result);
      }

      [TestMethod]
      public void IntPlusDoubleTest()
      {
         var math = new MathExtension();
         var result = math.Convert(2, null, "+ 3.0", CultureInfo.CurrentCulture);
         Assert.IsInstanceOfType(result, typeof(int));
         Assert.AreEqual(5, result);
      }

      [TestMethod]
      public void DoublePlusIntTest()
      {
         var math = new MathExtension();
         var result = math.Convert(2.0, null, "+ 3", CultureInfo.CurrentCulture);
         Assert.IsInstanceOfType(result, typeof(double));
         Assert.AreEqual(5.0, result);
      }

      [TestMethod]
      public void DoublePlusDoubleTest()
      {
         var math = new MathExtension();
         var result = math.Convert(2.0, null, "+ 3.0", CultureInfo.CurrentCulture);
         Assert.IsInstanceOfType(result, typeof(double));
         Assert.AreEqual(5.0, result);
      }

      [TestMethod]
      public void IntTimesIntTest()
      {
         var math = new MathExtension();
         var result = math.Convert(2, null, "* 3", CultureInfo.CurrentCulture);
         Assert.IsInstanceOfType(result, typeof(int));
         Assert.AreEqual(6, result);
      }

      [TestMethod]
      public void IntTimesDoubleTest()
      {
         var math = new MathExtension();
         var result = math.Convert(2, null, "* 3.5", CultureInfo.CurrentCulture);
         Assert.IsInstanceOfType(result, typeof(int));
         Assert.AreEqual(7, result);
      }

      [TestMethod]
      public void DoubleTimesIntTest()
      {
         var math = new MathExtension();
         var result = math.Convert(2.5, null, "* 3", CultureInfo.CurrentCulture);
         Assert.IsInstanceOfType(result, typeof(double));
         Assert.AreEqual(7.5, result);
      }

      [TestMethod]
      public void DoubleTimesDoubleTest()
      {
         var math = new MathExtension();
         var result = math.Convert(2.5, null, "* 3.5", CultureInfo.CurrentCulture);
         Assert.IsInstanceOfType(result, typeof(double));
         Assert.AreEqual(8.75, result);
      }
   }
}
